package com.cj.wisdom_display.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cj.wisdom_display.R;


public class ImageText extends RelativeLayout {

	private TextView txt1;
	private ImageView mImageView;
	private TextView txt2;
	private TextView txt3;

	public ImageText(Context context) {
		super(context);
		initView(context);
	}

	public ImageText(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView(context);
		TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ImgTxtValueView);
		int imageView = array.getResourceId(R.styleable.ImgTxtValueView_img, R.mipmap.ic_launcher);
		String txt1 = array.getString(R.styleable.ImgTxtValueView_txt1);
		String txt2 = array.getString(R.styleable.ImgTxtValueView_txt2);
		String txt3 = array.getString(R.styleable.ImgTxtValueView_txt3);

		this.txt1.setText(txt1);
		this.txt2.setText(txt2);
		this.txt3.setText(txt3);
		this.mImageView.setImageResource(imageView);

	}

	public ImageText(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		initView(context);
	}

	public void setTxt3(String s) {
		txt3.setText(s);
	}

	public void setTxt2(String s) {
		txt2.setText(s);
	}

	private void initView(Context context) {
		View.inflate(context, R.layout.item_weather, this);
		//iv_big = this.findViewById(R.id.iv_icon1);
		mImageView = this.findViewById(R.id.iv_data_img);
		txt1 = this.findViewById(R.id.tv_data_tips);
		txt2 = this.findViewById(R.id.tv_data_des);
		txt3 = this.findViewById(R.id.tv_text);
	}
}